/*
 * Copyright 2010 dev7.jp
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jp.dev7.android.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;

public class Layouts {

    private Layouts() {
    }

    public static LayoutInflater getLayoutInflater(Context context) {
        return (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @SuppressWarnings("unchecked")
    public static <T extends View> T inflate(Context context, int resource) {
        final LayoutInflater inflater = getLayoutInflater(context);
        return (T) inflater.inflate(resource, null, false);
    }

    public static LayoutParams getParamFillFill() {
        return new LayoutParams(
            LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);
    }

    public static LayoutParams getParamFillWrap() {
        return new LayoutParams(
            LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    }

    public static LayoutParams getParamWrapFill() {
        return new LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.FILL_PARENT);
    }

    public static LayoutParams getParamWrapWrap() {
        return new LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    }

}
